package com.wrench.elevator.jedis;

import java.util.Set;

import redis.clients.jedis.Jedis;

import com.wrench.elevator.constant.Dict;
import com.wrench.elevator.util.WrenchUtil;

public class JedisChengtiUtil
{
    public static Set<String> get(String user_id)
    {
        Jedis jedis = RedisUtil.getJedis();
        Set<String> value = null;
        String key = WrenchUtil.md5(Dict.USER_ID_SALT + user_id);
        value = jedis.smembers(key);
        RedisUtil.returnResource(jedis);
        return value;
    }
    
    public static void set(String user_id, String face_id_identity)
    {
        Jedis jedis = RedisUtil.getJedis();
        String key = WrenchUtil.md5(Dict.USER_ID_SALT + user_id);
        String key_BACK = key + "_BACK";
        jedis.sadd(key, face_id_identity);
        jedis.sadd(key_BACK, face_id_identity);
        jedis.expire(key, Dict.CHENGTI_CACHE_EXPIRE_TIME);
        jedis.expire(key_BACK, Dict.CHENGTI_BACK_CACHE_EXPIRE_TIME);
        RedisUtil.returnResource(jedis);
        
    }
    
    public static void add(String user_id, String face_id_identity)
    {
        Jedis jedis = RedisUtil.getJedis();
        String key = WrenchUtil.md5(Dict.USER_ID_SALT + user_id);
        String key_BACK = key + "_BACK";
        jedis.sadd(key, face_id_identity);
        jedis.sadd(key_BACK, face_id_identity);
        RedisUtil.returnResource(jedis);
    }
}
